/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"D922D8AA-ECD0-4CAA-957F-FE891B51D894"}
 */
function autoriza(event) {
	globals.gdeposito = entrega_lugar
	var $cant = oc_cabecera_to_oc_detalle.getSize()
	for (var i = 1 ; i <= $cant ; i++)
	{
		var $detalle = oc_cabecera_to_oc_detalle.getRecord(i)
		
		$detalle.oc_detalle_to_productos.stock_pend_recepcion += $detalle.cantidad
		$detalle.oc_detalle_to_productos.productos_to_existencias_x_dep.exi_pend_recepcion += $detalle.cantidad
	}
	oc_estado = 3
	filtrar()
}

/**
 * @properties={typeid:24,uuid:"7B39F679-7413-4F71-BAE1-91B6BC4F1A32"}
 * @AllowToRunInFind
 */
function filtrar()
{
	controller.find()
	oc_estado = 1
	controller.search()
}

/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"7B398157-D97D-46B3-8790-8598CAD07F21"}
 */
function iraDtl(event) {
	forms.oc_cabecera_dtl_dlg.controller.loadRecords(forms.oc_cabecera_autoriza.oc_cabecera_id)
	globals.formEnVentana('oc_cabecera_dtl_dlg','OC','Orden de Compra Nº '+ nro_oc)
}

/**
 * Callback method for when form is shown.
 *
 * @param {Boolean} firstShow form is shown first time after load
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"897C8717-8768-4E61-AF11-3AD29D0F9240"}
 */
function onShow(firstShow, event) {
	databaseManager.revertEditedRecords()
	databaseManager.setAutoSave(true)
	filtrar();
}
